package code.util.regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by chopin on 17/12/22.
 * 正则表达式验证指定中文
 *
 */
public class ChinaTest {

    public static void main(String[] args){
        ChinaTest test = new ChinaTest();
        test.testM1();
    }
    public void testM1(){

        this.m1("^[正]{1}[则]{1}[表]{1}[达]{1}[式]{1}$","正则表达式");
        this.m1("^([是]{1}|[否]{1})$","否");
    }
    private void m1(String reg, String str){
        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(str);
        if(matcher.find()){

            System.out.println(str+" , true");

        }else{
            System.out.println(str+" , false");

        }
    }
}
